package com.laowang.project.system.controller;

import java.util.List;

import com.laowang.framework.web.page.TableDataInfoMy;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyCyhReview;
import com.laowang.project.system.service.MyCyhReviewService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 精彩回顾Controller
 *
 * @author laowang
 * @date 2023-06-30
 */
@Api(tags = "精彩回顾接口")
@RestController
@RequestMapping("/review")
public class MyCyhReviewController extends BaseController {

    @Autowired
    private MyCyhReviewService myCyhReviewService;

    /**
     * 查询精彩回顾列表
     */
    @ApiOperation(value = "小程序端 查询精彩回顾列表",notes = "")
    @GetMapping("/web/list")
    public TableDataInfoMy weblist(MyCyhReview myCyhReview) {
        startPage();
        List<MyCyhReview> list = myCyhReviewService.selectMyCyhReviewListWeb(myCyhReview);
        return getDataTableMy(list);
    }


    /**
     * 查询精彩回顾列表
     */
    @ApiOperation(value = "查询精彩回顾列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:review:list')")
    @GetMapping("/list")
        public TableDataInfo list(MyCyhReview myCyhReview) {
        startPage();
        List<MyCyhReview> list = myCyhReviewService.selectMyCyhReviewList(myCyhReview);
        return getDataTable(list);
    }

    /**
     * 导出精彩回顾列表
     */
    @ApiOperation(value = "导出精彩回顾列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:review:export')")
    @Log(title = "精彩回顾", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyCyhReview myCyhReview) {
        List<MyCyhReview> list = myCyhReviewService.selectMyCyhReviewList(myCyhReview);
        ExcelUtil<MyCyhReview> util = new ExcelUtil<MyCyhReview>(MyCyhReview.class);
        return util.exportExcel(list, "review");
    }

    /**
     * 获取精彩回顾详细信息
     */
    @ApiOperation(value = "获取精彩回顾详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:review:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myCyhReviewService.selectMyCyhReviewById(id));
    }

    /**
     * 新增精彩回顾
     */
    @ApiOperation(value = "新增精彩回顾",notes = "")
    @PreAuthorize("@ss.hasPermi('my:review:add')")
    @Log(title = "精彩回顾", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyCyhReview myCyhReview) {
        return toAjax(myCyhReviewService.insertMyCyhReview(myCyhReview));
    }

    /**
     * 修改精彩回顾
     */
    @ApiOperation(value = "修改精彩回顾",notes = "")
    @PreAuthorize("@ss.hasPermi('my:review:edit')")
    @Log(title = "精彩回顾", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyCyhReview myCyhReview) {
        return toAjax(myCyhReviewService.updateMyCyhReview(myCyhReview));
    }

    /**
     * 删除精彩回顾
     */
    @ApiOperation(value = "删除精彩回顾",notes = "")
    @PreAuthorize("@ss.hasPermi('my:review:remove')")
    @Log(title = "精彩回顾", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myCyhReviewService.deleteMyCyhReviewByIds(ids));
    }
}
